Report for 18JB

Created on: 2025-07-15 13:00:51

Setup

Code
library(GeoPressureR)
library(ggplot2)
library(plotly)
library(terra)
library(tidyverse)
library(viridisLite)
library(sf)
library(rnaturalearth)
library(patchwork)

invisible(sapply(
  list.files("/Users/rafnuss/Library/CloudStorage/OneDrive-Vogelwarte/GeoMag/R", pattern = "\\.R$", full.names = TRUE),
  function(f) source(f, local = globalenv(), echo = FALSE)
))
id <- params$id
Code
tag <- tag_create(id,  directory = params$directory, quiet=T )
Code
subplot(plot(tag, "pressure"), plot(tag, "twilight", plot_plotly = T), plot(tag, "actogram", plot_plotly = T), nrows = 3, shareX = TRUE, titleY = TRUE)

Read and evaluate magnetic data

Code
tag <- geomag_calib(tag, calib_data=FALSE)

Plot acceleration

Code
df_magnetic <- tag$magnetic %>%
  filter(is_static < 1) %>%
  pivot_longer(acceleration_x:acceleration_z, names_to = "Component", values_to = "Value")

ggplot(df_magnetic, aes(x = Value)) +
  geom_histogram(bins = 30, fill = "steelblue", color = "black", alpha = 0.7) +
  facet_wrap(~Component, scales = "fixed") + # Fixed scales for uniform axes
  xlim(-max(abs(df_magnetic$Value)), max(abs(df_magnetic$Value))) +
  theme_minimal()

Code
plot_mag(tag,"acceleration")
Code
tag$magnetic %>%
  filter(is_static) %>%
  transmute(
    pitch = pitch / pi * 180,
    roll = roll / pi * 180
  ) %>%
  pivot_longer(cols = c(pitch, roll), names_to = "variable", values_to = "value") %>%
  ggplot(aes(x = value)) +
  geom_histogram(bins = 30, fill = "gray", color = "black") +
  facet_wrap(~variable, scales = "free_x") +
  labs(x = "Angle (degrees)", y = "Count") +
  theme_minimal()

Code
ggplotly(
  tag$magnetic %>%
    ggplot(aes(x = date, y = pitch/pi*180)) +
    geom_line(color = "grey") +
    geom_point(aes(color=is_static)) +
    theme_bw() +
    scale_y_continuous(name = "Pitch (°)"),
  dynamicTicks = TRUE
)
Code
plot_mag(tag, type="calib")
Code
plotly::plot_ly() |>
      plotly::add_markers(
        data = tag$mag_calib,
        x = ~magnetic_x, y = ~magnetic_y, z = ~magnetic_z,
        marker = list(color = as.numeric(tag$mag_calib$date))
      )
Code
subplot(
  ggplotly(
  tag$magnetic %>%
    ggplot(aes(x = date, y = I/pi*180)) +
    geom_point(aes(color=is_static)) +
    theme_bw() +
    scale_y_continuous(name = "Inclination (°)"),
  dynamicTicks = TRUE
),
ggplotly(
  tag$magnetic %>%
    ggplot(aes(x = date, y = F)) +
    geom_point(aes(color=is_static)) +
    theme_bw() +
    scale_y_continuous(name = "Intensity"),
  dynamicTicks = TRUE
),
  nrows = 2, shareX = TRUE, titleY = TRUE)